<template>
  <div class="login-container">
    <div class="login-register-container">
      <div class="login-rout">
        <router-link to="/szptLogin/login"
          ><div
            class="login-rout-div"
            v-bind:class="{ login_rout_div_actived: LoginIsActive }"
            @click="userLogin()"
          >
            登录
          </div></router-link
        >
        <router-link to="/szptLogin/register"
          ><div
            class="login-rout-div"
            v-bind:class="{ login_rout_div_actived: RegisterIsActive }"
            @click="userRegister()"
          >
            注册
          </div></router-link
        >
      </div>
      <div class="box-container">
        <router-view></router-view>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "SzptLogin",
  data() {
    return {
      // 判断是某个样式是否使用
      LoginIsActive: false,
      RegisterIsActive: false,
    };
  },
  methods: {
    userLogin() {
      // 用户登录
      this.LoginIsActive = true;
      this.RegisterIsActive = false;
    },
    userRegister() {
      // 用户注册
      this.LoginIsActive = false;
      this.RegisterIsActive = true;
    },
  },
  mounted() {
    if (this.$route.path !== "/szptLogin/login") {
      this.$router.replace("/szptLogin/login");
    }
    this.userLogin();
  },
};
</script>

<style scoped>
.login-container {
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  position: fixed;
  background-repeat: no-repeat;
  background-image: url("~@/assets/szptImages/images/bgpic.png");
  background-size: cover;
}
.login-register-container {
  width: 550px;
  height: 450px;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #fdfdfd;
  border-radius: 8px;
  overflow: hidden;
}
.login-rout {
  width: 100%;
  height: 60px;
  line-height: 60px;
  position: relative;
  font-size: 25px;
  background-color: transparent;
}
.login-rout-div {
  width: 48.5%;
  text-align: center;
  display: inline-block;
  cursor: pointer;
  color: #666;
}
.login_rout_div_actived {
  /*点击登录时候的按钮活跃颜色 */
  color: #409eff;
  font-weight: bold;
  border-bottom: 3px solid #409eff;
}
.login-rout div:hover {
  background-color: #f6f2f2;
}
.box-container {
  width: 100%;
  height: 387px;
  position: relative;
  top: 3px;
  background-color: transparent;
}
</style>
>
